kernel void multiply(global float * leftValues, global int * leftRows, global int * leftColumnIndexes, 
					 global float * rightValues, global int * rightRows, global int * rightColumnIndexes,
					 global float * result)
{
	int i = get_global_id(0);

	if (i >= SIZE) return;

	int temp[SIZE];

	for (int j = 0; j < SIZE; j++)
	{
		temp[j] = -1;
	}

	for (int j = rightColumnIndexes[i]; j < rightColumnIndexes[i + 1]; j++)
	{
		int row = rightRows[j];
		temp[row] = j;
	}

	for (int j = 0; j < SIZE; j++)
	{
		float sum = 0;

		for (int k = leftColumnIndexes[j]; k < leftColumnIndexes[j + 1]; k++)
		{
			int row = leftRows[k];
			int index = temp[row];

			if (index != -1)
			{
				sum += leftValues[k] * rightValues[index];
			}		
		}

		result[j * SIZE + i] = sum;
	}
}